//
//  StatusCellBottomCell.swift
//  Weibo
//
//  Created by 梁智 on 15/11/26.
//  Copyright © 2015年 lzfree. All rights reserved.
//

import UIKit

class StatusCellBottomCell: UIView {

    // MARK: - 构造函数
    override init(frame: CGRect) {
        super.init(frame: frame)
        setupUI()
    }

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    // MARK: - 懒加载控件
    /// 转发按钮
    private lazy var retweetedButton = UIButton(title: " 转发", imageName: "timeline_icon_retweet")
    /// 评论按钮
    private lazy var commentButton = UIButton(title: " 评论", imageName: "timeline_icon_comment")
    /// 赞
    private lazy var likeButton = UIButton(title: " 赞", imageName: "timeline_icon_unlike")
}


extension StatusCellBottomCell {
    
    private func setupUI() {
        backgroundColor = UIColor(white: 0.9, alpha: 1.0)
        
        addSubview(retweetedButton)
        addSubview(commentButton)
        addSubview(likeButton)
        
        retweetedButton.snp_makeConstraints { (make) -> Void in
            make.top.equalTo(self.snp_top)
            make.left.equalTo(self.snp_left)
            make.bottom.equalTo(self.snp_bottom)
        }
        commentButton.snp_makeConstraints { (make) -> Void in
            make.top.equalTo(retweetedButton.snp_top)
            make.left.equalTo(retweetedButton.snp_right)
            make.width.equalTo(retweetedButton.snp_width)
            make.height.equalTo(retweetedButton.snp_height)
        }
        likeButton.snp_makeConstraints { (make) -> Void in
            make.top.equalTo(commentButton.snp_top)
            make.left.equalTo(commentButton.snp_right)
            make.width.equalTo(commentButton.snp_width)
            make.height.equalTo(commentButton.snp_height)
            
            make.right.equalTo(self.snp_right)
        }
        
        // 分割视图
        let sepLeft = sepView()
        let sepRight = sepView()
        addSubview(sepLeft)
        addSubview(sepRight)
        
        let sepWidth = 0.5
        let sepScale = 0.4
        sepLeft.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(retweetedButton.snp_right)
            make.centerY.equalTo(retweetedButton.snp_centerY)
            make.height.equalTo(retweetedButton.snp_height).multipliedBy(sepScale)
            make.width.equalTo(sepWidth)
        }
        sepRight.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(commentButton.snp_right)
            make.centerY.equalTo(commentButton.snp_centerY)
            make.height.equalTo(commentButton.snp_height).multipliedBy(sepScale)
            make.width.equalTo(sepWidth)
        }
    }
    
    
    
    /// 分割线视图
    private func sepView() -> UIView {
        let v = UIView()
        v.backgroundColor = UIColor.redColor()
        return v
    }
}
